<?php
class RepairesController extends AppController {
	public $helpers = array('Html', 'Form', 'Session');
	public $components = array('Session');


	public function index() {
		$this->set('repaires', $this->Repaire->find('all'));
	}

	public function view($id) {
		$this->Repaire->id = $id;
		$this->set('repaire', $this->Repaire->read());
	}


	public function add() {
		if ($this->request->is('post')) {
			$this->Repair->create();
			if ($this->Repair->save($this->request->data)) {
				$this->Session->setFlash('Se han guardado los cambios.');
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash('No se pudieron guardar los cambios.');
			}
		}
	}

	public function edit($id = null) {
		$this->Repaire->id = $id;
		if ($this->request->is('get')) {
			$this->request->data = $this->Repaire->read();
		} else {
			if ($this->Repaire->save($this->request->data)) {
				$this->Session->setFlash('Datos actualizados correctamente.');
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash('No se pudieron guardar los cambios.');
			}
		}
	}

}